QuaternaryList class¶
Attributes: [DefaultMember("Item")] [DebuggerDisplay("QuaternaryList: {Count}")]
Defined in
Namespace: ReactiveList.Reactive.Collections Assembly: ReactiveList.Reactive.dll Full name: ReactiveList.Reactive.Collections.QuaternaryList<T> Modifiers: public sealed
Summary¶
View source (opens in a new tab)
Represents a high-performance, thread-safe list that partitions its elements across four internal shards for
efficient concurrent access and batch operations. Supports secondary indexing for fast lookups by custom keys.
Applies to
net11.0, net10.0, net47, net471, net472, net48, net481
Class hierarchy
classDiagram
class QuaternaryList~T~
class IQuaternaryList~T~ {
<>
}
IQuaternaryList~T~ <|.. QuaternaryList~T~
class ICollection~T~ {
<>
}
ICollection~T~ <|.. QuaternaryList~T~
class IEnumerable~T~ {
<>
}
IEnumerable~T~ <|.. QuaternaryList~T~
class IEnumerable {
<>
}
IEnumerable <|.. QuaternaryList~T~
class IReactiveSource~T~ {
<>
}
IReactiveSource~T~ <|.. QuaternaryList~T~
class INotifyCollectionChanged {
<>
}
INotifyCollectionChanged <|.. QuaternaryList~T~
class IDisposable {
<>
}
IDisposable <|.. QuaternaryList~T~
class IVersionedSnapshotSource~T~ {
<>
}
IVersionedSnapshotSource~T~ <|.. QuaternaryList~T~
class INotifyPropertyChanged {
<>
}
INotifyPropertyChanged <|.. QuaternaryList~T~
class IReactiveSourceWithOptions {
<>
}
IReactiveSourceWithOptions <|.. QuaternaryList~T~
Implements: IQuaternaryList
Remarks¶
QuaternaryList{T} is optimized for scenarios involving frequent additions, removals, and batch operations on large datasets. Internally, items are distributed across four shards, each guarded by its own reader-writer lock, to reduce contention and improve parallelism. Operations that touch several shards take the locks in ascending shard order. Change notifications are queued while the shard lock is still held, so observers see changes in the order they happened, and are delivered by a single background reader. After Dispose every operation that reads or writes items throws ObjectDisposedException (opens in a new tab). The collection is not read-only and supports dynamic growth. Secondary indices can be added to enable efficient lookups by arbitrary keys. All public methods are thread-safe. The list may hold equal items more than once; an index returns one entry per copy. Enumeration, ToArray and Snapshot work on a point-in-time copy, so a consumer can call back into the list while enumerating. Direct index-based operations (such as Insert, RemoveAt, or setting by index) are not supported and will throw exceptions; use Add, Remove, or batch methods instead. The callbacks given to Edit run while every shard is locked and must not call back into the list.
Constructors¶
| Name | Summary |
|---|---|
| .ctor | Initializes a new instance of the QuaternaryList class. |
Properties¶
| Name | Summary |
|---|---|
| Count | Gets the total number of items contained in all shards. |
| IsReadOnly | Gets a value indicating whether the collection is read-only. |
| Stream | Gets an observable sequence that emits cache change notifications as they occur. |
| VersionedStream | Gets an observable of change notifications, each paired with the version the change produced. |
| Options | Gets the options that apply for the lifetime of the source. |
| IsDisposed | Gets a value indicating whether the object has been disposed. |
| Version | Gets the current version number of the collection, which is incremented on each modification. |
| this[] | Gets or sets the element at the specified index. |
Methods¶
| Name | Summary |
|---|---|
| Add | Adds the specified item to the collection. |
| Remove | Removes the specified item from the collection. |
| Clear | Removes all items from the cache. |
| DeferNotifications | Defers change notifications until the last active deferral is disposed. |
| Dispose | Releases all resources used by the current instance. |
| AddRange | Adds the elements of the specified collection to the current set. |
| RemoveRange | Removes all elements in the specified collection from the current set. |
| RemoveMany | Removes all elements that match the specified predicate from the collection. |
| Edit | Performs a batch edit operation on the collection, ensuring only a single change notification is emitted. |
| ReplaceAll | Replaces all existing items with new items atomically, emitting a single change notification. |
| AddIndex | Adds a secondary index to enable efficient lookups based on a specified key selector. |
| GetItemsBySecondaryIndex | Retrieves all entities of type T that match the specified key in the given secondary index. |
| ItemMatchesSecondaryIndex | Determines whether the specified item matches the given key in the specified secondary index. |
| Contains | Determines whether the collection contains a specific value. |
| CopyTo | Copies the elements of the collection to an array. |
| ToArray | Returns an array containing all elements in the collection. |
| CopyVersioned | Copies every item and reports the version of that copy. |
| GetEnumerator | Returns an enumerator over a point-in-time copy of the collection. |
| Snapshot | Creates a snapshot of the current items as a read-only list. |
Events¶
| Name | Summary |
|---|---|
| CollectionChanged | Occurs when the collection changes. |
| PropertyChanged | Occurs when a property value changes. |
Inherited members
System.Object.Equals(System.Object)(opens in a new tab)System.Object.Equals(System.Object,System.Object)(opens in a new tab)System.Object.GetHashCode(opens in a new tab)System.Object.GetType(opens in a new tab)System.Object.MemberwiseClone(opens in a new tab)System.Object.ReferenceEquals(System.Object,System.Object)(opens in a new tab)System.Object.ToString(opens in a new tab)